package designPatterns.P02_工厂模式_Factory.P01_简单工厂.P01_PizzaStore.第1版_无工厂.order;

import designPatterns.P02_工厂模式_Factory.P01_简单工厂.P01_PizzaStore.第1版_无工厂.pizza.CheesePizza;
import designPatterns.P02_工厂模式_Factory.P01_简单工厂.P01_PizzaStore.第1版_无工厂.pizza.GreekPizza;
import designPatterns.P02_工厂模式_Factory.P01_简单工厂.P01_PizzaStore.第1版_无工厂.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author d11yu
 */
public class OrderPizza {
    public OrderPizza() {
        Pizza pizza = null;
        String orderType;
        loop:
        do {
            orderType = getType();
            switch (orderType) {
                case "greek":
                    pizza = new GreekPizza();
                    break;
                case "cheese":
                    pizza = new CheesePizza();
                    break;
                default:
                    break loop;
            }
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }

    private String getType() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("input pizza type:");
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }
}
